package com.example.logisticsingle.security.bcrypt;

import com.example.logisticsingle.security.bcrypt.BCryptPasswordEncoder;
/**
 * BCryptPasswordEncoder加密工具类
 *
 */
public class BCryptUtil {
    /**
     * 对字符串加密
     * @param password	加密对象字符串
     * @return	已加密结果字符串
     */
    public static String encode(String password) {
       BCryptPasswordEncoder bCryptPasswordEncoder = new BCryptPasswordEncoder();
        return bCryptPasswordEncoder.encode(password);
    }
    /**
     * 验证密码是否和已加密对象字符串匹配
     * @param password	密码字符串
     * @param encodePassword	已加密对象字符串
     * @return
     */
    public static boolean isMatch(String password, String encodePassword) {
       BCryptPasswordEncoder bCryptPasswordEncoder = new BCryptPasswordEncoder();
        return bCryptPasswordEncoder.matches(password, encodePassword);
    }

}
